﻿using System;
using YArchitech.HCLoad.Utils;

namespace YArchitech.HCLoad.Export
{
	public class HcValueRange
	{
		public double Max
		{
			get
			{
				return this.m_max;
			}
		}

		public double Min
		{
			get
			{
				return this.m_min;
			}
		}

		public RangeFilterType RangeFilterType
		{
			get
			{
				return this.m_rangeType;
			}
		}

		public HcValueRange(double v1, double v2, RangeFilterType rangeType)
		{
			this.m_rangeType = rangeType;
			this.Set(v1, v2);
		}

		public bool InRange(double dTest)
		{
			return dTest < this.Max && dTest > this.Min;
		}

		private bool Set(double v1, double v2)
		{
			switch (this.m_rangeType)
			{
			case RangeFilterType.eGreaterThan:
				this.m_min = v1;
				this.m_max = double.MaxValue;
				break;
			case RangeFilterType.eLessThan:
				this.m_max = v2;
				this.m_min = double.MinValue;
				break;
			case RangeFilterType.eInRange:
				if (v1 > v2)
				{
					this.m_min = v2;
					this.m_max = v1;
				}
				else
				{
					this.m_min = v1;
					this.m_max = v2;
				}
				break;
			}
			return true;
		}

		private double m_min;

		private double m_max;

		private RangeFilterType m_rangeType;
	}
}
